package com.arvato.minipro.bean.bean_dto.common;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Describe：用来将界面的请求参数 封装成map的实体
 * 
 * @author smallking
 *
 *  2017年10月13日
 */
public class Query extends LinkedHashMap<String, Object> {
	
	private static final long serialVersionUID = 1L;
	
	private Integer pageNum = 1;
	
	private Integer pageSize = 20;
	
	public Query(){
		super();
	}
	
	public Query(Map<String, Object> query){
		for(String key : query.keySet()){
			Object value = query.get(key);
			if(value instanceof String){
				if(!(value.toString().trim().equals(""))){
					this.put(key, value);
				}
			}else{
				this.put(key, "");
			}
		}
		Object obj1 = query.get("pageNum");
		Object obj2 = query.get("pageSize");
		if(obj1 != null){
			this.pageNum = Integer.valueOf((String)obj1);
			if(this.pageNum == 0){
				this.pageNum = 1;
			}
		}
		if(obj2 != null){
			this.pageSize = Integer.valueOf((String)obj2);
			if(this.pageSize == 0){
				this.pageSize = 20;
			}
		}
		if(query.get("relation") == null){
			this.put("relation", "and");
		}
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}
	
}
